package com.example.springboot.mapper;

import com.example.springboot.entity.Favorites;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 收藏表 Mapper 接口
 * </p>
 *
 * @author
 * @since
 */
public interface FavoritesMapper extends BaseMapper<Favorites> {
    @Select("SELECT COUNT(1) FROM favorites WHERE homestay_id = #{homestayId} AND user_id = #{userId}")
    Integer selectisLikes(@Param("homestayId")Integer homestayId, @Param("userId")Integer userId);

    @Delete("DELETE FROM favorites WHERE homestay_id = #{homestayId} AND user_id = #{userId}")
    void deleteisLikesById(@Param("homestayId")Integer homestayId, @Param("userId")Integer userId);
}
